package com.spdg.ring.service;

import com.spdg.ring.bo.PushBo;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import cn.wolf.tools.Log;

/**
 * <p>Title: 推送自啟動服務     </p>
 * <p>Description: 
 *  提供自啟動服務，供推送使用
 * </p>
 * <p>@author: Eric.wsd                </p>
 * <p>Copyright: Copyright (c) 2012    </p>
 * <p>Company: FFCS Co., Ltd.          </p>
 * <p>Create Time: 2012-10-10             </p>
 * <p>Update Time:                     </p>
 * <p>Updater:                         </p>
 * <p>Update Comments:                 </p>
 */
public class PushService extends Service {
	public static final String PUSH_SERVICE_ACTION = "com.spdg.ring.service.PushService";

	public static boolean isEnable = Boolean.FALSE; // 是否启动服务

	@Override
	public IBinder onBind(Intent intent) {
		return null;
	}

	@Override
	public void onCreate() {
		super.onCreate();

		initData();

		isEnable = Boolean.TRUE;
		Log.i("start push service!");
	}

	/**
	 * 初始化数据
	 */
	private void initData() {
		startPushAlarm();
	}

	/**
	 * 启动消息通知定时器
	 */
	private void startPushAlarm() {
		PushBo bo = new PushBo(this);
		bo.startAlarm();
	}

	@Override
	public void onDestroy() {
		super.onDestroy();

		startPushAlarm();
		isEnable = Boolean.FALSE;
		Log.i("stop push service!");
	}
}
